package domain.controllers;



import domain.Entity.EntityUsuario;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.view.RedirectView;

/**
 *
 * @author jorge
 */
public class invalidarController implements Controller{
    
    
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        
         ModelAndView mav = new ModelAndView();
         HttpSession session = request.getSession();
        EntityUsuario eu = (EntityUsuario) session.getAttribute("usuario");
        if(eu == null){
            mav.setView(new RedirectView("login.htm"));
            return mav;
        }else{
         
         session.invalidate();
         mav.setView(new RedirectView("login.htm"));
       
         return mav ;
        }
    }
}    